import requset from './request';
import querystring from 'query-string';

/** ------------------------------------ 商品接口 ----------------------------------------------- */

export const getGoodsList = (params) => requset({url: '/projectList', method: 'get', params})

export const getSearch = (params) => requset({url: '/search', method: 'get', params})

export const getCategory = (params) => requset({url: '/backend/itemCategory/selectItemCategoryByParentId', method: 'get', params})

export const uploadUrl = 'http://127.0.0.1:7878/upload'; // 图片上传接口

export const addGoods = (params) => requset({url: '/backend/item/insertTbItem', method: 'get', params})

export const deleteGoods = (params) => requset({url: '/backend/item/deleteItemById', method: 'get', params})

export const updateGoods = (params) => requset({url: '/backend/item/updateTbItem', method: 'get', params})

/** ------------------------------------ 登录注册接口 ----------------------------------------------- */

// 登录接口后端不支持传对象，需要转字符串
export const login = (userInfo) => requset({url: '/login', method: 'post', data: querystring.stringify(userInfo)})

export const register = (userInfo) => requset({url: '/register', method: 'post', data: querystring.stringify(userInfo)})

export const getUserList = (params) => requset({url: '/userList', method: 'get', params})

export const getUserSearch = (params) => requset({url: '/user/search', method: 'get', params})

export const addUser = (userInfo) => requset({url: '/register', method: 'post', data: querystring.stringify(userInfo)})

export const deleteUser = (params) => requset({url: '/user/delete', method: 'get', params})

export const updateUser = (params) => requset({url: '/update/userInfo', method: 'get', params})

/** ------------------------------------ 规格参数接口 ----------------------------------------------- */

export const getParams = (params) => requset({url: '/backend/itemParam/selectItemParamAll', method: 'get', params})

export const addParams = (params) => requset({url: '/backend/itemParam/insertItemParam', method: 'get', params})

export const getCategoryData = (params) => requset({url: '/category/data', method: 'get', params})

export const getParamsSearch = (params) => requset({url: '/params/search', method: 'get', params})

export const updateParams = (params) => requset({url: '/update/category', method: 'get', params})

export const deleteParams = (params) => requset({url: '/params/delete', method: 'get', params})

/** ------------------------------------ 规格参数接口 ----------------------------------------------- */

export const getOrderList = () => requset({url: '/order', method: 'get'})